import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/Layout'

export const constantRoutes = [{
        path: '/login',
        name: 'Login',
        component: () =>
            import ('@/views/login'),
        isTop: false,
        meta: {
            title: '登录-绩效管理平台',
            icon: 'apps-line',
        },
    }, {
        path: '/',
        name: 'Layout',
        component: Layout,
        redirect: '/index',
        isTop: true,
        meta: {
            title: '首页',
            icon: 'apps-line',
        },
        children: [{
            path: 'index',
            name: 'Index',
            component: () =>
                import ('@/views'),
            meta: {
                title: '首页',
                icon: 'icon-shouye',
            },
        }, ],
    }, {
        path: '/403',
        name: '403',
        component: () =>
            import ('@/views/403'),
        isTop: false,
    },
    {
        path: '/404',
        name: '404',
        component: () =>
            import ('@/views/404'),
        isTop: false,
    }
]

export const asyncRoutes = [{
        path: '/notice-manager',
        component: Layout,
        redirect: '/notice-manager/not-read',
        isTop: true,
        meta: {
            title: '公告管理',
            icon: 'apps-line',
        },
        children: [{
                path: '/notice-manager/not-read',
                name: 'not-read',
                component: () =>
                    import ('@/views/notice-manager/has-read'),
                meta: {
                    title: '我接收的',
                    icon: 'icon-weiduxiaoxi-05',
                    id: 3, //id=3 假设为我接收的公告
                },
            },
            {
                path: '/notice-manager/has-read',
                name: 'has-read',
                component: () =>
                    import ('@/views/notice-manager/has-read'),
                meta: {
                    title: '我发布的',
                    icon: 'icon-yidu',
                    id: 2 //id=2 假设为我发布的公告
                },
            },
        ],
    },
    {
        path: '/role-manager',
        component: Layout,
        redirect: '/role-manager/roles-manager1',
        isTop: true,
        meta: {
            title: '角色管理',
            icon: 'apps-line',
        },
        children: [{
                path: '/role-manager/roles-manager1',
                name: 'roles-manager1',
                component: () =>
                    import ('@/views/roles-manager'),
                meta: {
                    title: '默认分组',
                    icon: 'icon-dian',
                },
            },

        ],
    },
    {
        path: '/enterprise-manager',
        component: Layout,
        redirect: '/enterprise-manager/enterprise-manager',
        isTop: true,
        meta: {
            title: '企业管理',
            icon: 'apps-line',
        },
        children: [{
            path: '/enterprise-manager/enterprise-manager',
            name: 'enterprise-manager',
            component: () =>
                import ('@/views/enterprise-manager'),
            meta: {
                title: '企业管理',
                icon: 'icon-dian',
            },
        }, ],
    },
    {
        path: '/approve-manager',
        component: Layout,
        redirect: '/approve-manager/all-approve',
        isTop: true,
        meta: {
            title: '审批管理',
            icon: 'apps-line',
        },
        children: [{
            path: '/approve-manager/all-approve',
            name: 'approve-all',
            component: () =>
                import ('@/views/approve-manager'),
            meta: {
                title: '全部项目',
                icon: 'icon-dian',
                id: 1, //全部项目id
            },
        }, {
            path: '/approve-manager/my-applicat',
            name: 'my-applicat',
            component: () =>
                import ('@/views/approve-manager'),
            meta: {
                title: '我的申请',
                icon: 'icon-dian',
                id: 2, //我的申请id
            },
        }, {
            path: '/approve-manager/my-aduit',
            name: 'my-aduit',
            component: () =>
                import ('@/views/approve-manager'),
            meta: {
                title: '我审批的',
                icon: 'icon-dian',
                id: 3, //我审批的id
            },
        }, {
            path: '/approve-manager/my-recive',
            name: 'my-recive',
            component: () =>
                import ('@/views/approve-manager'),
            meta: {
                title: '抄送我的',
                icon: 'icon-dian',
                id: 3, //抄送我的id
            },
        }],
    },
    {
        path: '/program-manager',
        component: Layout,
        redirect: '/program-manager/all-program',
        isTop: true,
        meta: {
            title: '项目管理',
            icon: 'apps-line',
        },
        children: [{
            path: '/program-manager/all-program',
            name: 'all-program',
            component: () =>
                import ('@/views/program-manager'),
            meta: {
                title: '全部项目',
                icon: 'icon-dian',
                id: 1, //全部项目id
            },
        }, {
            path: '/program-manager/my-program',
            name: 'my-program',
            component: () =>
                import ('@/views/program-manager'),
            meta: {
                title: '我的项目',
                icon: 'icon-dian',
                id: 2, //我的申请id
            },
        }, {
            path: '/program-manager/program-detail',
            name: 'program-detail',
            component: () =>
                import ('@/views/program-manager/program-detail'),
            meta: {
                title: '项目详情',
                icon: 'icon-dian',
            },
            hidden: true //代表不在右边菜单出现
        }, {
            path: '/program-manager/program-basic-info',
            name: 'program-basic-info',
            component: () =>
                import ('@/views/program-manager/program-basic-info'),
            meta: {
                title: '项目基本信息',
                icon: 'icon-dian',
            },
            hidden: true //代表不在右边菜单出现
        }, {
            path: '/program-manager/part-program',
            name: 'part-program',
            component: () =>
                import ('@/views/program-manager'),
            meta: {
                title: '部门项目',
                icon: 'icon-dian',
                id: 3, //我审批的id
            },
        }, {
            path: '/program-manager/next-part-program',
            name: 'next-part-program',
            component: () =>
                import ('@/views/program-manager'),
            meta: {
                title: '下属部门项目',
                icon: 'icon-dian',
                id: 4, //抄送我的id
            },
        }, {
            path: '/program-manager/program-data',
            name: 'program-data',
            component: () =>
                import ('@/views/program-manager'),
            meta: {
                title: '项目资料库',
                icon: 'icon-dian',
                id: 5, //抄送我的id
            },
        }],
    },
    {
        path: '/statistics-manager',
        component: Layout,
        redirect: '/statistics-manager/index',
        isTop: true,
        meta: {
            title: '数据统计与分析',
            icon: 'apps-line',
        },
        children: [{
            path: '/statistics-manager/index',
            name: 'statistics-manager',
            component: () =>
                import ('@/views/statistics-manager'),
            meta: {
                title: '数据统计与分析',
                icon: 'icon-dian',
            },
        }],
    },
    {
        path: '/set-manager',
        component: Layout,
        redirect: '/set-manager/plan-cycle',
        isTop: true,
        meta: {
            title: '设置',
            icon: 'apps-line',
        },
        children: [{
                path: '/set-manager/plan-cycle',
                name: 'plan-cycle',
                component: () =>
                    import ('@/views/set-manager/plan-cycle'),
                meta: {
                    title: '计划周期',
                    icon: 'icon-dian',
                },
            },
            {
                path: '/set-manager/workflow-template',
                name: 'workflow-template',
                component: () =>
                    import ('@/views/set-manager/workflow-template'),
                meta: {
                    title: '工作流模板',
                    icon: 'icon-dian',
                },
            },
            {
                path: '/set-manager/approval-template',
                name: 'approval-template',
                component: () =>
                    import ('@/views/set-manager/approval-template'),
                meta: {
                    title: '审批模板',
                    icon: 'icon-dian',
                },
            },
            {
                path: '/set-manager/reproject-monitor',
                name: 'reproject-monitor',
                component: () =>
                    import ('@/views/set-manager/reproject-monitor'),
                meta: {
                    title: '重复立项监测',
                    icon: 'icon-dian',
                },
            },
            {
                path: '/set-manager/role-manage',
                name: 'role-manage',
                component: () =>
                    import ('@/views/set-manager/role-manage'),
                meta: {
                    title: '角色管理',
                    icon: 'icon-dian',
                },
            },
            {
                path: '/set-manager/enterprise-manage',
                name: 'enterprise-manage',
                component: () =>
                    import ('@/views/set-manager/enterprise-manage'),
                meta: {
                    title: '企业管理',
                    icon: 'icon-dian',
                },
            },
        ],
    },
    {
        path: '/*',
        redirect: '/404',
        hidden: true,
        isTop: false,
    },
]

const router = createRouter({
    history: createWebHashHistory(process.env.BASE_URL),
    routes: [...constantRoutes, ...asyncRoutes]
})

export default router